<?php

class Application_Form_SendLink extends Zend_Form
{

    public function init()
    {
        $this->setMethod('post')
        	->setAttrib('id', 'sendLinkForm');
        
        $this->clearDecorators();
        
        $decorators = array(
        		array('ViewHelper'),
        		array('Errors'),
        		array('Label', array('requiredSuffix' => ' *', 'class' => 'leftalign')),
        		array('HtmlTag', array('tag' => 'li')),
        );
        
        $id = $this->addElement('hidden', 'id');
        $id = $this->getElement('id')
        		->addFilter('Int');
        
        $generatedUrl = $this->addElement('textarea', 'generated_url',
        		array('label' => 'Order Form Link'));
        $generatedUrl = $this->getElement('generated_url')
        		->setRequired(true)
        		->addFilter('StringTrim')
        		->setAttrib('readonly', 'true');
        $generatedUrl->setDecorators($decorators);
        
        $sendToEmail = $this->addElement('text', 'send_to_email',
        		array('label' => 'Customer Email'));
        $sendToEmail = $this->getElement('send_to_email')
        		->addValidator('EmailAddress')
        		->setRequired(true)
        		->addFilter('StringTrim');
        $sendToEmail->getValidator('EmailAddress')->setMessage('Invalid email address');
        $sendToEmail->setDecorators($decorators);
        
        $sendLink = $this->addElement('submit', 'send_link',
        		array('label' => 'Send Link'));
        $sendLink = $this->getElement('send_link')
        		->setDecorators(array(
        			array('ViewHelper'),
        ));
        
        $discard = $this->addElement('submit', 'discard',
        		array('label' => 'Discard'));
        $discard = $this->getElement('discard')
        		->setDecorators(array(
        			array('ViewHelper'),
        ));
        
        $this->addDisplayGroup(array('send_link', 'discard'), 'submit_buttons',
        		array('disableLoadDefaultDecorators' => true));
        $submitButtons = $this->getDisplayGroup('submit_buttons');
        $submitButtons->addDecorators(array(
        		array('FormElements', 'Form'),
        		array('HtmlTag', array('tag' => 'li', 'class' => 'submit')),
        ));
        
        $this->setDecorators(array(
        		'FormElements',
        		array('HtmlTag', array('tag' => 'ul')),
        		array(array('DivTag' => 'HtmlTag'),
        				array('tag' => 'div', 'id' => 'sendLinkDiv')),
        		'Form'
        ));
    }


}

